﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using YGame.Base;

namespace YGame.GameThing
{
	public class ThingRepository
	{
		static Dictionary<int, IGoods> s_GoodsMap;
		static int s_goodsMaxRid = 0;

		public static void Init()
		{
			Trace.Write("YGame.GameThing.ThingRepository install.\r\n", YGame.Base.TraceType.Info.ToString()); 
			s_GoodsMap = new Dictionary<int, IGoods>();
		}

		public static void Release()
		{
			Trace.Write("YGame.GameThing.ThingRepository Release.\r\n", YGame.Base.TraceType.Info.ToString());
			if (s_GoodsMap != null)
			{
				s_GoodsMap.Clear();
				s_GoodsMap = null;
			}
		}

		public static IGoods CreateGoods(int goodsID)
		{
			Goods goods = new Goods() { RID=s_goodsMaxRid, GoodsID = goodsID };
			s_GoodsMap.Add(s_goodsMaxRid++, goods);
			return goods;
		}

		public static bool RemoveGoods(int goodsRID)
		{
			return s_GoodsMap.Remove(goodsRID);
		}


	}
}
